﻿// =====================================================================
// <copyright file="ConfigExtensions.cs" author="David R. Guindo">
// 	Copyright (C) 2013. All rights reserved.
// </copyright>
// =====================================================================
// This code is released under the terms of the Apache 2.0 license, 
// http://apache.org/licenses/LICENSE-2.0.html
// =====================================================================

namespace System
{
    using AppBlock.Core;

    /// <summary>
    /// </summary>
    public static class ConfigExtensions
    {
        /// <summary>
        ///     Gets the app setting.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">The name.</param>
        /// <returns>``0.</returns>
        public static T AppSettingsGet<T>(this string name)
        {
            return ConfigHelper.GetAppSetting<T>(name);
        }

        /// <summary>
        ///     Get Application settings value from config file.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">The name.</param>
        /// <param name="defaultValue">The default value.</param>
        /// <returns>``0.</returns>
        public static T AppSettingsGet<T>(this string name, T defaultValue)
        {
            return ConfigHelper.GetAppSetting<T>(name, defaultValue);
        }

        /// <summary>
        ///     Get Application settings value from config file.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="defaultValue">The default value.</param>
        /// <returns>System.String.</returns>
        public static string AppSettingsGet(this string name, string defaultValue = null)
        {
            return ConfigHelper.GetAppSetting<string>(name, defaultValue);
        }
    }
}